package com.itmuch.contentcenter.sentineltest;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.UrlCleaner;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.el.stream.Stream;
import org.codehaus.stax2.ri.typed.NumberUtil;
import org.springframework.stereotype.Component;

import java.util.Arrays;

//@Component
@Slf4j
public class MyUrlCleaner implements UrlCleaner {
    @Override
    public String clean(String s) {
        log.info("ssssssssssssss:"+s);
      String[] shuju = s.split("/");
      Arrays.asList(shuju).forEach(System.out::println);

        String temp = Arrays.stream(shuju)
                .map( a->{
                    if (NumberUtils.isDigits(a)){
                        return "{number}";
                    }else return  a;
                } )
                .reduce((a,b)->a+"/"+b)
                .orElse("");
         log.info(temp);
        return temp;
    }
}
